﻿/*
 * Created by SharpDevelop.
 * Author: Taranu Bogdan
 * Date: 5/4/2012
 * Time: 3:08 PM
 */
using System;

namespace SensorClient
{
    /// <summary>
    /// Contains constants and enumerations relevant to the format of the
    /// package
    /// </summary>
    public static class PackageFormat
    {

        #region Constants
        /// <summary>
        /// The length of the vector containing the values of the ECG samples
        /// </summary>
        public const int ECG_VECTOR_LENGTH = 100;
        /// <summary>
        /// The size of an ECG sample is equal 2 bytes
        /// </summary>
        public const int ECG_ELEMENT_SIZE = 2;
        /// <summary>
        /// The size of a HTA sample is equal to 2 bytes
        /// </summary>
        public const int HTA_ELEMENT_SIZE = 2;
        /// <summary>
        /// The size of a pulse sample is equal to 2 bytes
        /// </summary>
        public const int PULSE_ELEMENT_SIZE = 2;
        /// <summary>
        /// The size of a body temperature sample is equal to 2 bytes
        /// </summary>
        public const int BODY_TEMPERATURE_ELEMENT_SIZE = 2;
        /// <summary>
        /// The size of a weight sample is equal to 3 bytes 
        /// (2 for the integer part, 1 for the fractional part)
        /// </summary>
        public const int WEIGHT_ELEMENT_SIZE = 3;
        /// <summary>
        /// The size of a glicemia sample is equal to 2 bytes
        /// </summary>
        public const int GLICEMY_ELEMENT_SIZE = 2;
        /// <summary>
        /// The size of a respiratory frequency sample is equal to 1 byte
        /// </summary>
        public const int RESPIRATORY_FREQUENCY_ELEMENT_SIZE = 1;
        /// <summary>
        /// The size of a ambient temperature sample is equal to 2 bytes
        /// </summary>
        public const int AMBIENT_TEMPERATURE_ELEMENT_SIZE = 2;
        /// <summary>
        /// The size of a humidity sample is equal to 2 bytes
        /// </summary>
        public const int HUMIDITY_ELEMENT_SIZE = 2;
        /// <summary>
        /// The size of a light sample is equal to 2 bytes
        /// </summary>
        public const int LIGHT_ELEMENT_SIZE = 2;
        /// <summary>
        /// The size of element containing the boolean values
        /// of the RFID, voltage and gas sensors is 1 byte
        /// </summary>
        public const int RFID_VOLTAGE_GAS_ELEMENT_SIZE = 1;
        /// <summary>
        /// The position of the RFID sensor bit
        /// </summary>
        public const int RFID_SHIFT = 0;
        /// <summary>
        /// The position of the voltage sensor bit
        /// </summary>
        public const int VOLTAGE_SHIFT = 1;
        /// <summary>
        /// The position of the gas sensor bit
        /// </summary>
        public const int GAS_SHIFT = 2;
        #endregion

        #region Enumerations
        /// <summary>
        /// An enumeration containing the start index of each sensor 
        /// from the package
        /// </summary>
        public enum SensorPositionStart
        {
            ECG = 0,
            HTA = ECG + ECG_VECTOR_LENGTH * ECG_ELEMENT_SIZE,
            PULSE = HTA + HTA_ELEMENT_SIZE,
            BODY_TEMPERATURE = PULSE + PULSE_ELEMENT_SIZE,
            WEIGHT = BODY_TEMPERATURE + BODY_TEMPERATURE_ELEMENT_SIZE,
            GLICEMY = WEIGHT + WEIGHT_ELEMENT_SIZE,
            RESPIRATORY_FREQUENCY = GLICEMY + GLICEMY_ELEMENT_SIZE,
            AMBIENT_TEMPERATURE = RESPIRATORY_FREQUENCY +
                                  RESPIRATORY_FREQUENCY_ELEMENT_SIZE,
            HUMIDITY = AMBIENT_TEMPERATURE + AMBIENT_TEMPERATURE_ELEMENT_SIZE,
            LIGHT = HUMIDITY + HUMIDITY_ELEMENT_SIZE,
            RFID_VOLTAGE_GAS = LIGHT + LIGHT_ELEMENT_SIZE,
            TOTAL = RFID_VOLTAGE_GAS + RFID_VOLTAGE_GAS_ELEMENT_SIZE,
        }
        /// <summary>
        /// An enumeration containing the end index of each sensor 
        /// from the package
        /// </summary>
        public enum SensorPositionStop
        {
            ECG = PackageFormat.SensorPositionStart.HTA,
            HTA = PackageFormat.SensorPositionStart.PULSE,
            PULSE = PackageFormat.SensorPositionStart.BODY_TEMPERATURE,
            WEIGHT = PackageFormat.SensorPositionStart.GLICEMY,
            GLICEMY = PackageFormat.SensorPositionStart.RESPIRATORY_FREQUENCY,
            RESPIRATORY_FREQUENCY = PackageFormat.SensorPositionStart.AMBIENT_TEMPERATURE,
            AMBIENT_TEMPERATURE = PackageFormat.SensorPositionStart.HUMIDITY,
            HUMIDITY = PackageFormat.SensorPositionStart.LIGHT,
            LIGHT = PackageFormat.SensorPositionStart.RFID_VOLTAGE_GAS,
            RFID_VOLTAGE_GAS = PackageFormat.SensorPositionStart.TOTAL,
        }
        /// <summary>
        /// An enumeration containg the maximum values obtainable
        /// from x bit numbers.
        /// </summary>
        public enum BitMaxValues
        {
            ONE_BIT_MAX = 1,
            THREE_BITS_MAX = 7,
            FOUR_BITS_MAX = 15,
            EIGHT_BITS_MAX = 255,
            TEN_BITS_MAX = 1023,
        }
        #endregion
    }
}